import 'package:banyou_app/app/config/colors.dart';
import 'package:banyou_app/app/routes/app_pages.dart';
import 'package:banyou_app/app/util/common_utils.dart';
import 'package:banyou_app/app/widget/app_bar_widget.dart';
import 'package:banyou_app/app/widget/load_network_image_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../controllers/remenjingdian_controller.dart';

class RemenjingdianView extends GetView<RemenjingdianController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget(titleStr: '热门城市景点'),
      body: SafeArea(
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 16),
          child: ListView.separated(
              padding: EdgeInsets.zero,
              // shrinkWrap: true,
              // physics: NeverScrollableScrollPhysics(),
              itemBuilder: (c, i) {
                return itemWidget(controller.dataList[i],i);
              },
              separatorBuilder: (c, i) {
                return Container(
                  height: 10,
                );
              },
              itemCount: controller.dataList.length),
        ),
      ),
    );
  }

  Widget itemWidget(Map item, int index) {
    List projects = (item['Projects'] ?? []);
    String projectsStr = projects.join('、');
    return InkWell(
      onTap: () {
        String full = box.read("full") ?? "";
        if (full.isNotEmpty) {
          showMang(full);
        } else {
          Get.toNamed(Routes.JINGDIANXIANGQING, arguments: item);
        }
       
      },
      child: Container(
        child: Row(
          children: [
            Container(
              width: 138.w,
              height: 148.w,
              clipBehavior: Clip.hardEdge,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(10.r)),
              ),
              child: Stack(
                children: [
                  Positioned.fill(
                    child: LoadNetworkImageWidget(
                        fit: BoxFit.cover,
                        height: double.infinity,
                        imageUrl: item['PictureUrl'] ?? ""),
                  ),
                  Positioned(
                    top: 0,
                    left: 0,
                    width: 42,
                    height: 18,
                    child: Stack(
                      children: [
                        Positioned.fill(
                            child: Image.asset('assets/images/路径 20@2x.png')),
                        Positioned.fill(
                            child: Center(
                          child: Text(
                            'TOP' + (index + 1).toString(),
                            style: TextStyle(
                              color: ColorConfig.white,
                              fontSize: 10,
                            ),
                          ),
                        )),
                      ],
                    ),
                  )
                ],
              ),
            ),
            SizedBox(width: 10),
            Expanded(
                child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  item['Title'] ?? "",
                  style: TextStyle(
                    color: ColorConfig.text_label,
                    fontWeight: FontWeight.bold,
                    fontSize: 16.sp,
                  ),
                ),
                SizedBox(height: 10),
                Row(
                  children: [
                    Container(
                      padding:
                          EdgeInsets.symmetric(horizontal: 10, vertical: 5),
                      decoration: BoxDecoration(
                        gradient: LinearGradient(
                            begin: Alignment.centerLeft,
                            end: Alignment.centerRight,
                            colors: [
                              Color(0xFFE6F1FC),
                              Color(0xFFFFE4FE),
                            ]),
                        borderRadius: BorderRadius.circular(22),
                      ),
                      child: Center(
                        child: Text(
                          item['Selection'] ?? "",
                          style: TextStyle(
                            color: ColorConfig.text_label,
                            fontSize: 10,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 20),
                Text(
                  "项目：" + projectsStr,
                  style: TextStyle(
                    color: Color(0xFF959595),
                    fontSize: 10.sp,
                  ),
                ),
              ],
            ))
          ],
        ),
      ),
    );
  }
}
